<template>
	<view>
		<view class="banner">
			<swiper class="swiper" indicator-active-color="#FFFFFF" :current="bannerindex" :autoplay="true" :interval="5000" :duration="500" circular  @change="bannercg">
				<block v-for="(banner,index) in bannerList" :key="index">
					<swiper-item>
						<image :src="banner" @click="priviews(bannerList,index)" mode="aspectFill"></image>
					</swiper-item>
				</block>
			</swiper>
			<view class="banner-inter">
				<view class="banner-inter-item" @click="setActive(bindex)" :class="{'banner-inter-active': bannerindex == bindex}"  v-for="(banner,bindex) in bannerList" :key="bindex"></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"banner",
		props:{
			bannerList:{
				type:Array,
				default:()=>{
					return []
				}
			}
		},
		data() {
			return {
				bannerindex: 0,
			}
		},
		methods:{
			bannercg(e){
				this.bannerindex = e.detail.current;
			},
			setActive(index){
				this.bannerindex = index;
			},
			priviews(imgs,i){
				uni.previewImage({
					urls:imgs,
					current:i
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.banner{
	width: 750rpx;
	height: 750rpx;
	position: relative;
	
	.swiper{
		@include img;
	}
	
	image{
		@include img;
	}
	
	&-inter{
		width: 100%;
		position: absolute;
		left: 0;
		bottom: 24rpx;
		z-index: 9;
		@include center;
		
		&-item{
			width: 16rpx;
			height: 16rpx;
			background: #FFFFFF;
			opacity: 0.5;
			border-radius: 50%;
			margin: 0 5rpx; 
			transition: all 0.4s;
		}
		&-active{
			width: 70rpx;
			height: 16rpx;
			background: #FFFFFF;
			border-radius: 8rpx;
			opacity: 1;
		}
	}
}
</style>
